Unless otherwise indicated herein, the materials described in this section are not prior art to the claims in this application and are not admitted to be prior art by inclusion in this section.
Copy-on-write (“COW”) can be understood as a memory optimization technique that is commonly performed in computer systems. COW can be performed by an operating system (“OS”) in a non-virtual environment or by a hypervisor in a virtual environment. In an example implementation of COW, a parent process may create a child process via a fork OS call. When the child process is created, an OS may cause the parent process to share its pages with the child process, rather than create a separate copy of the parent process's pages for the child process. The OS may also impose write protection on the shared pages.
When either the parent process or the child process writes to a shared page, the write protection may cause the OS to raise a write protection exception. In response to the write protection exception, the OS may allocate a child process's page and copy contents of the parent process's page to the child process's page. For example, the OS may execute a loop of load and store operations adapted to copy each word from the parent process's page to the child process's page. The OS may then turn off the write protection on the shared page and return from the exception.
Conventional COW mechanisms suffer from various drawbacks. First, conventional COW mechanisms may involve a central processing unit (“CPU”), thereby occupying the CPU from performing other operations. In particular, the OS may instruct the CPU to copy data from the parent process's page to the child process's page using, for example, the loop of load and store operations. Second, conventional COW mechanisms may result in superfluous copying. In particular, the OS may instruct the CPU to copy each byte or word from the parent process's page to the child process's page, even though the parent process's page and the child process's page may differ by only a few bytes or words. Third, conventional COW mechanisms may result in cache inefficiency. In particular, during the copy process, the parent process's page and the child process's page may be brought into the cache, regardless of whether the data is needed by the CPU. Fourth, conventional COW mechanisms may not be scalable for future computing systems that implement larger page sizes. In particular, because conventional COW mechanisms copy entire pages, larger page sizes may worsen the other drawbacks described above, thereby making such COW mechanisms prohibitively expensive.